package cn.dujc.superkid.adapter;


import android.support.annotation.Nullable;
import android.text.Html;
import android.view.View;
import android.widget.ImageView;

import java.util.List;

import cn.dujc.core.adapter.BaseAdapter;
import cn.dujc.core.adapter.BaseViewHolder;
import cn.dujc.superkid.R;
import cn.dujc.superkid.bean.MyAskResult;
import cn.dujc.superkid.utils.DateUtil;
import cn.dujc.superkid.utils.ImageLoadHelper;

public class MyQuestionAdapter extends BaseAdapter<MyAskResult.MyAskEntity> {
    public MyQuestionAdapter(@Nullable List<MyAskResult.MyAskEntity> data) {
        super(data);
        mLayoutResId= R.layout.que_ans_item;
    }

    @Override
    protected void convert(BaseViewHolder helper, MyAskResult.MyAskEntity item) {
        /*
        *  private String id;//问题id
        *  private String problem_posttime;//提问时间
        *  private String problem_content;//提问内容
        *  private String answer_teacher_id;//回答问题老师id
        *  private String answer_posttime;//回答问题时间
        *  private String answer_content;//回答问题内容
        *  private String status;//状态(1-未回复，2-已回复)
        *  private String problem_username;//提问提的名字
        *  private String problem_avatar;//提问题的头像
        *  private String answer_teacher_nicename;//回答问题的老师名字
        *  private String answer_teacher_avatar;//回答问题的老师头像
        * */
        long problem_posttime = Long.valueOf(item.getProblem_posttime()).longValue();
        String posttime= DateUtil.formatData("yyyy-MM-dd HH:mm:ss",problem_posttime);
        helper.setText(R.id.que_name,item.getProblem_username());
        helper.setText(R.id.question,item.getProblem_content());
        helper.setText(R.id.que_time,posttime);
        ImageLoadHelper.loadImage((ImageView) helper.getView(R.id.que_icon),item.getProblem_avatar());//暂无头像
        if(item.getStatus().equals("1")){
            helper.setGone(R.id.rl_alreadyprocessed,false);
            helper.setGone(R.id.rl_untreated,true);
        }else {
            long answer_posttime = Long.valueOf(item.getAnswer_posttime()).longValue();
            String posttime2=DateUtil.formatData("yyyy-MM-dd HH:mm:ss",answer_posttime);
            helper.setText(R.id.teacher_time,posttime2);
            ImageLoadHelper.loadImage((ImageView) helper.getView(R.id.teacher_icon),item.getAnswer_teacher_avatar());//暂无头像
            helper.setText(R.id.teacher_name,item.getAnswer_teacher_nicename());
            helper.setText(R.id.teacher_answer,Html.fromHtml(item.getAnswer_content()));
        }
    }
}
